from django.db import models
from apps.common.models import CommonItem
# Create your models here.

class Post(CommonItem):
	title = models.CharField(max_length=90)
	slug = models.SlugField(max_length=40)
	body = models.TextField()
			   
	@models.permalink
	def get_absolute_url(self):
		return ('post_view', (), {
				'year': self.created_at.year,
				'month': self.created_at.month,
				'day': self.created_at.day,
				'slug': self.slug})

	def __unicode__(self):
		return self.title

class Comment(CommonItem):
	post = models.ForeignKey(Post)
	body = models.TextField()
	
	def __unicode__(self):
		return self.id
